﻿package mortal.game.scene3D.ai.singleAIs.autofight
{
    import flash.geom.*;
    import mortal.game.cache.*;
    import mortal.game.scene3D.ai.ais.*;
    import mortal.game.scene3D.player.entity.*;

    public class AutofightStrategy_CopyDefence extends AutofightStrategyBase
    {
        private var range:int = 1200;
        public static var instance:AutofightStrategy_CopyDefence = new AutofightStrategy_CopyDefence;

        public function AutofightStrategy_CopyDefence()
        {
            return;
        }// end function

        override public function setParams(param1:AutoFightAI) : void
        {
            super.setParams(param1);
            AutoFightBossSelectAI.instance.isOnlyInRange = true;
            Cache.instance.copy.defenseCopy.isCopyEnd = false;
            var _loc_2:* = new Rectangle();
            _loc_2.x = RolePlayer.instance.x2d - this.range;
            _loc_2.y = RolePlayer.instance.y2d - this.range;
            _loc_2.width = this.range * 2;
            _loc_2.height = this.range * 2;
            AutoFightBossSelectAI.instance.rangRect = _loc_2;
            return;
        }// end function

        override public function chooseMovePath() : void
        {
            var _loc_1:Point = null;
            if (Cache.instance.copy.defenseCopy.isCopyEnd)
            {
                return;
            }
            if (_ai.data.range <= 0)
            {
                Cache.instance.autoFight.resetToNearestBossPoint(false);
                Cache.instance.autoFight.setToNextBossRefreshPoint(true);
                _loc_1 = Cache.instance.autoFight.getCurBossRereshPoint();
            }
            else
            {
                _loc_1 = AutoFightBossSelectAI.instance.sourcePoint;
            }
            if (_loc_1 == null)
            {
                return;
            }
            AutoFightBossSelectAI.instance.sourcePoint.x = _loc_1.x;
            AutoFightBossSelectAI.instance.sourcePoint.y = _loc_1.y;
            AutoFightBossSelectAI.instance.rangRect.x = _loc_1.x - this.range;
            AutoFightBossSelectAI.instance.rangRect.y = _loc_1.y - this.range;
            _ai.cancelAll();
            _ai.addMoveTo(_loc_1, 20);
            _ai.startAIList();
            return;
        }// end function

    }
}
